This repository was archived by the owner on May 15, 2026. It is now read-only.
feat: add support for VSCode file encodings - #11042
Draft
ghost wants to merge 1 commit into
Draft
Conversation
- Add iconv-lite dependency for encoding conversion - Create src/utils/fileEncoding.ts utility that: - Gets file encoding from VSCode settings (files.encoding) - Provides readFileWithEncoding() and writeFileWithEncoding() functions - Includes fallback to UTF-8 if encoding conversion fails - Update DiffViewProvider.ts to use encoding-aware file operations - Update ApplyPatchTool.ts to use encoding-aware file operations - Add comprehensive tests for the encoding utility Fixes #11002
Author
Review completed. No issues found. The implementation correctly adds encoding support for VSCode's Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
|
Looking forward... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related GitHub Issue
Closes: #11002
Description
This PR attempts to address Issue #11002 by adding support for VSCode file encodings.
Problem: Roo Code previously hardcoded UTF-8 encoding for all file read/write operations. When editing files with non-UTF-8 encodings (like CP 852), the content was read as UTF-8, modified, and written back as UTF-8, which corrupted special characters (e.g., č, ć, ž, š, đ).
Solution: This PR implements encoding detection and preservation:
New encoding utility (
src/utils/fileEncoding.ts):files.encoding)readFileWithEncoding()andwriteFileWithEncoding()functionsModified
DiffViewProvider.ts:Modified
ApplyPatchTool.ts:Added
iconv-litedependency:Test Procedure
cd src && npx vitest run utils/__tests__/fileEncoding.spec.ts- all 17 tests pass"files.encoding": "cp852"for a workspacePre-Submission Checklist
Screenshots / Videos
N/A - No UI changes, this is a backend encoding fix.
Documentation Updates
files.encodingsetting.Additional Notes
This implementation follows the user's requested approach from the issue discussion:
Feedback and guidance are welcome!
Important
Adds support for VSCode file encodings, enabling encoding-aware file operations and fallback to UTF-8 if conversion fails.
readFileWithEncoding()andwriteFileWithEncoding()infileEncoding.tsto handle file encodings based on VSCode settings.DiffViewProvider.tsto use encoding-aware reading and writing for file operations.ApplyPatchTool.tsto use encoding-aware reading and writing for patch operations.iconv-litetopackage.jsonfor encoding conversion support.fileEncoding.spec.tsto verify encoding handling and fallback behavior.This description was created by
for 57f07a8. You can customize this summary. It will automatically update as commits are pushed.